package com.flight.trans.adapter;

import android.content.Context;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.flight.trans.R;
import com.flight.trans.base.BaseRecyclerAdapter;
import com.flight.trans.base.BaseViewHolder;
import com.flight.trans.bean.StoreroomInventoryBean.StoreroomInventoryData;
import com.flight.trans.util.CommonUtils;

import java.util.List;

/**
 * 盘库
 */
public class StoreroomInventoryAdapter extends BaseRecyclerAdapter<StoreroomInventoryData> {

    public StoreroomInventoryAdapter(Context mContext, List<StoreroomInventoryData> mList) {
        super(mContext, mList);
    }

    @Override
    public int setContentView() {
        return R.layout.adapter_storeroom_inventory;
    }

    @Override
    protected void bindData(BaseViewHolder holder, StoreroomInventoryData data, int position) {
        LinearLayout mLlContainerItem = holder.findViewById(R.id.mLlContainerItem);

        TextView mTvOrderCount = holder.findViewById(R.id.mTvOrderCount);
        TextView mTvUndoneOrderCount = holder.findViewById(R.id.mTvUndoneOrderCount);
        TextView mTvCreatePerson = holder.findViewById(R.id.mTvCreatePerson);
        TextView mTvInventoryTime = holder.findViewById(R.id.mTvInventoryTime);
        TextView mTvInventoryStatus = holder.findViewById(R.id.mTvInventoryStatus);

        mTvOrderCount.setText(String.valueOf(data.getOrderCnt()));
        mTvUndoneOrderCount.setText(String.valueOf(data.getUndoneOrderCnt()));
        mTvCreatePerson.setText(data.getUserName());
        mTvInventoryTime.setText(CommonUtils.getTimeNorm(data.getCreateTime()));
        mTvInventoryStatus.setText(mContext.getString(data.isDone() ? R.string.text_finish : R.string.text_not_finish));

        mLlContainerItem.setBackground(mContext.getDrawable(data.isLocked() ? R.color.color_red : R.drawable.selector_cyan_line));

        setOnItemClickListener(mLlContainerItem , position);
    }
}
